package com.asia5b.a5mall.middleware.model.bean

import android.content.Intent
import com.alibaba.android.arouter.facade.Postcard
import com.asia5b.a5mall.middleware.model.base.BaseModel
import com.asia5b.a5mall.middleware.utils.JsonUtil
import com.google.gson.reflect.TypeToken

/**
 * Created by zhangyuncai on 2020/4/15.
 */
class CheckSmsBean(var checkSmsType: CheckSmsType) : BaseModel() {
    companion object {
        fun getCheckSmsBean(intent: Intent): CheckSmsBean {
            return intent.getSerializableExtra("type") as CheckSmsBean
        }

    }

    fun putParams(intent: Intent) {
        intent.putExtra("type", this)
    }
    fun putParams(postcard: Postcard) {
        postcard.withSerializable("type", this)
    }

    fun cloneCheckSmsBean(): CheckSmsBean {
        val anyToJson = JsonUtil.anyToJson(this)
        val type = object : TypeToken<CheckSmsBean>() {}.type
        return JsonUtil.jsonToAny<CheckSmsBean>(anyToJson, type)!!
    }

    //可能是账号,可能是纯数字手机号,可能是中间4位数被隐藏的手机号
    var mobile: String = ""

    //国家编码 中国为+86
    var areaCode: String = ""

    //手机短信验证码
    var smsCode: String = ""

    //图片验证码
    var imageCode: String = ""

    //REGISTER_USER_OR_BIND_PHONE专用
    var connectInfo: ConnectLoginBean? = null

    //修改手机号发送验证码方式,true:校验 false:修改
    var editPasswordValidateMobile = true

}

/*
todo 修改登录密码流程
发送图片校验码 VALIDATE_MOBILE https://apimall.asiajy.com/base/captchas/6721fac0-ab8d-11ea-b442-25c71ee4ee1c/VALIDATE_MOBILE?r=1591846418956
发送短信 members/security/send https://apimall.asiajy.com/buyer/members/security/send
验证短信 members/security/password https://apimall.asiajy.com/buyer/members/security/password?sms_code=1111
输入密码,再次发送图片校验码 https://apimall.asiajy.com/base/captchas/6721fac0-ab8d-11ea-b442-25c71ee4ee1c/MODIFY_PASSWORD?r=1591846510610
确认修改密码 https://apimall.asiajy.com/buyer/members/security/password
 */

/*
todo 忘记密码
发送图片校验码 https://apimall.asiajy.com/base/captchas/6721fac0-ab8d-11ea-b442-25c71ee4ee1c/FIND_PASSWORD?r=1591857390344
验证账户 https://apimall.asiajy.com/buyer/passport/find-pwd?uuid=6721fac0-ab8d-11ea-b442-25c71ee4ee1c&captcha=1111&account=15589636926
再次发送图片校验码 https://apimall.asiajy.com/base/captchas/51a5e8e535ae481e891a197ea6083d90/FIND_PASSWORD?r=1591857427300
发送短信 https://apimall.asiajy.com/buyer/passport/find-pwd/send
验证短信 https://apimall.asiajy.com/buyer/passport/find-pwd/valid?uuid=51a5e8e535ae481e891a197ea6083d90&sms_code=1111
第三次发送图片校验码(可选) https://apimall.asiajy.com/base/captchas/51a5e8e535ae481e891a197ea6083d90/FIND_PASSWORD?r=1591857470243,可以不需要
确认设置密码 https://apimall.asiajy.com/buyer/passport/find-pwd/update-password
 */

/*
todo 注册
验证用户名是否合法(可选) https://apimall.asiajy.com/buyer/passport/username/m_1110
验证手机号是否合法(可选) https://apimall.asiajy.com/buyer/passport/mobile/15881111110
发送图片校验码  https://apimall.asiajy.com/base/captchas/a87527d2d0a74d24b123e9c4c5e05b05/REGISTER http/1.1
发送短信  https://apimall.asiajy.com/buyer/passport/register/smscode/15881111112?uuid=a87527d2d0a74d24b123e9c4c5e05b05&captcha=1111&gr=86 http/1.1
核对短信  https://apimall.asiajy.com/buyer/passport/smscode/15881111112?scene=REGISTER&sms_code=1111&gr=86 http/1.1
设置密码  https://apimall.asiajy.com/buyer/passport/register/wap?mobile=15881111112&password=96e79218965eb72c92a549dd5a330112&gr=86 http/1.1
 */

/*
todo 修改手机号码
发送图片校验码 https://apimall.asiajy.com/base/captchas/009191e252e3423ebe726ca7576ad867/VALIDATE_MOBILE http/1.1
发送短信 https://apimall.asiajy.com/buyer/members/security/send?captcha=1111&uuid=009191e252e3423ebe726ca7576ad867 http/1.1
核对短信 https://apimall.asiajy.com/buyer/members/security/exchange-bind?sms_code=1111 http/1.1
再次发送图片校验码 https://apimall.asiajy.com/base/captchas/009191e252e3423ebe726ca7576ad867/BIND_MOBILE http/1.1
再次发送短信  https://apimall.asiajy.com/buyer/members/security/bind/send/15589636929?captcha=1111&uuid=009191e252e3423ebe726ca7576ad867&gr=86 (200ms)
再次核对短信 https://apimall.asiajy.com/buyer/members/security/exchange-bind/15589636929?sms_code=1111&gr=86 http/1.1
 */